Date picker: Don't clear value while user edits (closes #22738)#22996
Date picker: Don't clear value while user edits (closes #22738)#22996AndyButland wants to merge 2 commits into
Conversation
|
Claude finished @AndyButland's task in 4m 10s —— View job PR ReviewTarget: Fixes a browser-specific edge case where
Suggestions
Approved with Suggestions for improvementGood to go — the core fix is correct, well-reasoned, and the three test cases cover the key scenarios described in the PR. The suggestions above are minor and don't block merging. Labels applied: |
There was a problem hiding this comment.
Pull request overview
Fixes a regression where typing into a native <input type="date"> (or time/datetime-local) caused the entire value to be wiped while the user was mid-edit. The browser reports a transiently empty .value for partial input (e.g. a single 0 in a month segment), and UUI's reactive value binding then programmatically cleared every segment. UmbInputDateElement now overrides onInput to skip reflecting empty values, and uses focusout to commit/clear once editing finishes.
Changes:
- Override
onInputinUmbInputDateElementto ignore transient empty native values, while still dispatching aninputevent. - Add a
focusoutlistener that syncsvaluefrom the native input and dispatchesinput/changeif the user committed an intentional clear. - Add regression tests covering the no-reflect, normal-reflect, and focusout-commits-clear paths; fix a typo ("demonination" → "denomination") in the class JSDoc.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Umbraco.Web.UI.Client/src/packages/core/components/input-date/input-date.element.ts |
Add onInput override and focusout listener; fix JSDoc typo. |
src/Umbraco.Web.UI.Client/src/packages/core/components/input-date/input-date.test.ts |
Add three regression tests for transient empty inputs and focusout commit behavior. |
leekelleher
left a comment
There was a problem hiding this comment.
Tested this out, it works when entering a zero 0 for the day and/or month parts, but not the year part. e.g. if I try to replace 2026 with 2025, the value will empty after I input 20.
I'll try look for a fix.
Interesting. That's what the original report is about on the issue, but I couldn't seem to replicate that. I could type "2026" fine without anything tripping up on the "0". I would only see the issue typing a "0" for the month. Maybe there's a browser/operating system difference? |
|
I'm on Windows 11 / Chrome (148). Just tried with Firefox (151) and it all works as expected. |
|
Also using Windows 11/Chrome - so actually that doesn't really explain it. I'll check again... no, seems I don't see it. Weird. |
Description
When typing into a date property, the browser briefly reports an empty value while the typed digit doesn't yet form a valid date — e.g. a single
0typed into add.MM.yyyymonth segment before the second digit.uui-input.onInputreflected that empty value back into the underlying<input>via Lit's reactive.valuebinding, which programmatically clears all segments of a<input type="date">— wiping the digit just typed and every other already-filled segment.UmbInputDateElementnow overridesonInputto skip the empty reflection while the user is editing, and afocusoutlistener syncs the value (and re-dispatchesinput/change) so an intentional clear still propagates.Fixes #22738.
Testing
Automated
A test was added in
input-date.test.tscovering the fix.Manual
27.05.2026.0(intending to enter04).4) now leaves27.04.2026in place. Before this change, the first0keystroke wiped the whole input.